package com.lst.demo.pickview;

import android.graphics.Color;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.bigkoo.pickerview.view.TimePickerView;
import com.lst.demo.R;

import java.util.Calendar;
import java.util.Date;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 选择时间日期对话框
 */
public class TimePickViewActivity extends AppCompatActivity {

    @BindView(R.id.tv_time)
    TextView tvTime;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_timepickview);
        ButterKnife.bind(this);
    }

    @OnClick(R.id.tv_time)
    public void onViewClicked() {

        Calendar startcalendar = Calendar.getInstance();
        startcalendar.set(2000, 0, 1);//设置开始的年月日(2000年1月1日),月份是从0-11

        Calendar endcalendar = Calendar.getInstance();//如果不设置,就默认是当前日期
        // endcalendar.set(2050, 0, 1);


        TimePickerView pvTime = new TimePickerBuilder(this, new OnTimeSelectListener() {
            @Override
            public void onTimeSelect(Date date, View v) {

            }
        }).isCyclic(false)
                .setItemVisibleCount(7)//设置显示可见的条目数,默认是9
                .setLineSpacingMultiplier(3)//设置间距倍数 1.0-4.0之间
                .setDividerColor(Color.parseColor("#ff0000"))//设置分割线颜色
                .setType(new boolean[]{true, true, false, false, false, false})
                .setDate(Calendar.getInstance())//设置当前日期
                .setRangDate(startcalendar, endcalendar)//设置列表起止日期
                .isDialog(false)//是否是对话框模式
                .build();
        pvTime.show(true);

    }
}
